package com.hanma.service.impl;

import com.hanma.bean.Comments;
import com.hanma.dao.CommentsDao;
import com.hanma.dao.impl.CommentsDaoImpl;
import com.hanma.service.CommentsService;

import java.util.Collections;
import java.util.List;

public class CommentsServiceImpl implements CommentsService {
    @Override
    public boolean insert(Comments comments) {
        CommentsDao dao = new CommentsDaoImpl();
        int num = dao.insert(comments);
        if(num>0) {
            return true;
        }
        return false;
    }

    @Override
    public boolean delete(Integer id) {
        return false;
    }

    @Override
    public boolean update(Comments comments) {
        return false;
    }

    @Override
    public boolean updateHead(Integer uid, String img) {
        CommentsDao dao = new CommentsDaoImpl();
        return dao.updateHead(uid,img)>0;
    }

    @Override
    public boolean updateNickname(Integer uid, String nickname) {
        CommentsDao dao = new CommentsDaoImpl();
        return dao.updateNickname(uid,nickname)>0;
    }

    @Override
    public Comments find(Integer id) {
        return null;
    }

    @Override
    public List<Comments> findAll(Integer nid) {
        CommentsDao dao = new CommentsDaoImpl();
        return dao.findAll(nid);
    }

    @Override
    public List<Comments> findAllUser(Integer uid) {
        CommentsDao dao = new CommentsDaoImpl();
        return dao.findAllUser(uid);
    }

    @Override
    public List<Comments> findAllUser(Integer uid, Integer start, Integer size) {
        CommentsDao dao = new CommentsDaoImpl();
        return dao.findAllUser(uid,start,size);
    }
}
